// @ts-ignore
import { api } from '@/utils/api';

/** 新增通用树主信息表数据 POST /treeMain/add */
export async function treeMainAdd(
  body: BASE.TreeMain,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResult>;

export async function treeMainAdd(
  body: BASE.TreeMain,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResult>>;

export async function treeMainAdd(
  body: BASE.TreeMain,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResult>;

export async function treeMainAdd(body: BASE.TreeMain, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResult>(`/app/treeMain/add`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResult>(`/app/treeMain/add`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 删除通用树主信息表数据 POST /treeMain/delete */
export async function treeMainDelete(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResult>;

export async function treeMainDelete(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResult>>;

export async function treeMainDelete(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResult>;

export async function treeMainDelete(body: BASE.ID, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResult>(`/app/treeMain/delete`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResult>(`/app/treeMain/delete`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 获取通用树主信息表数据 POST /treeMain/get */
export async function treeMainGet(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultTreeMain>;

export async function treeMainGet(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultTreeMain>>;

export async function treeMainGet(
  body: BASE.ID,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultTreeMain>;

export async function treeMainGet(body: BASE.ID, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultTreeMain>(`/app/treeMain/get`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultTreeMain>(`/app/treeMain/get`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 获取所有树住信息 POST /treeMain/list */
export async function treeMainList(
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultListTreeMain>;

export async function treeMainList(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultListTreeMain>>;

export async function treeMainList(
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultListTreeMain>;

export async function treeMainList(options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultListTreeMain>(`/app/treeMain/list`, {
      method: 'POST',
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultListTreeMain>(`/app/treeMain/list`, {
    method: 'POST',
    ...(options || {})
  });
}

/** 获取通用树主信息表分页数据 POST /treeMain/page */
export async function treeMainPage(
  body: BASE.TreeMainQuery,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResultIPageTreeMain>;

export async function treeMainPage(
  body: BASE.TreeMainQuery,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResultIPageTreeMain>>;

export async function treeMainPage(
  body: BASE.TreeMainQuery,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResultIPageTreeMain>;

export async function treeMainPage(
  body: BASE.TreeMainQuery,
  options?: ArgumentsType<typeof api>[1]
) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResultIPageTreeMain>(`/app/treeMain/page`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResultIPageTreeMain>(`/app/treeMain/page`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}

/** 更新通用树主信息表数据 POST /treeMain/update */
export async function treeMainUpdate(
  body: BASE.TreeMain,
  options?: ArgumentsType<typeof api>[1]
): Promise<BASE.IResult>;

export async function treeMainUpdate(
  body: BASE.TreeMain,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: true }
): Promise<TupleResponse<BASE.IResult>>;

export async function treeMainUpdate(
  body: BASE.TreeMain,
  options?: ArgumentsType<typeof api>[1] & { tupleResponse: false }
): Promise<BASE.IResult>;

export async function treeMainUpdate(body: BASE.TreeMain, options?: ArgumentsType<typeof api>[1]) {
  if (
    (
      options as ArgumentsType<typeof api>[1] & {
        tupleResponse: boolean;
      }
    )?.tupleResponse === true
  ) {
    return api<BASE.IResult>(`/app/treeMain/update`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      data: body,
      ...(options || {}),
      tupleResponse: true
    });
  }

  return api<BASE.IResult>(`/app/treeMain/update`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  });
}
